<!doctype html>
<html>
<head>
	<meta charset="utf-8"/>
	<title>后台管理中心</title>
	<link rel="stylesheet" type="text/css" href="../user/css/showUser.css">
    <script src="../lib/vue.js"></script>
    <script src="../lib/axios.js"></script>
    <link rel="stylesheet" href="../css/layout.css" type="text/css" media="screen" />
    <script src="../js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../js/hideshow.js" type="text/javascript"></script>
    <script src="../js/jquery.tablesorter.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../js/jquery.equalHeight.js"></script>
    <script src="../api/approval_api.js"></script>
    <script type="text/javascript">
        $(function(){
            $('.column').equalHeight();
        });
    </script>
    <script type="text/javascript">
        setInterval(function() {
            var now = (new Date()).toLocaleString();
            $('.current-time').text(now);
        }, 1000);
    </script>

</head>


<body>

	<header id="header">
		<hgroup>
			<h1 class="site_title"><a href="#">人力资源管理系统</a></h1>
			<h2 class="section_title"></h2><div class="btn_view_site"><a href="login.html">注销</a></div>
		</hgroup>
	</header> <!-- end of header bar -->
	
	<section id="secondary_bar">
		<div class="user">
			<p id="staff"></p>
			<!-- <a class="logout_user" href="#" title="Logout">Logout</a> -->
		</div>
		<div class="breadcrumbs_container">
			<article class="breadcrumbs"><a href="index.html">系统管理中心</a> <div class="breadcrumb_divider"></div> <a class="current">应聘信息查看</a></article>
			<div class="current-time"></div>
		</div>
	</section><!-- end of secondary bar -->

	<aside id="sidebar" class="column">
     <h3>人员信息管理</h3>
     <ul class="toggle">
        <li class="icn_new_article"><a href="lecadd.html">人员信息录入</a></li>
        <li class="icn_see_onlineUser"><a href="leclist.html">人员信息查看</a></li>
        
    </ul>

    <h3>应聘信息管理</h3>
    <ul class="toggle">
        <li class="icn_new_article"><a href="hireinfo.html">应聘信息录入</a></li>
        <li class="icn_see_onlineUser"><a href="rencaiku.html">应聘信息查看</a></li>
        <li class="icn_categories"><a href="approval.html">应聘信息审核</a></li>
    </ul>

    <h3>公告管理</h3>
    <ul class="toggle">
       <li class="icn_new_article"><a href="notice_add.html">公告添加</a></li>

       <li class="icn_categories"><a href="notice_edit.html">公告编辑</a></li>

       <li class="icn_see_onlineUser"><a href="notice_check.html">公告查看</a></li>



   </ul>




   <footer>

   </footer>
</aside><!-- end of sidebar -->


<section id="main" class="column">

  <article class="module width_full" style="width:95%">
      <header><h3 class="tabs_involved">应聘信息表</h3>
      </header>
      <div class="tab_container" id="app" >
       <div id="tab1" class="tab_content" >
        <table class="tablesorter" cellspacing="0" style="margin:0"  white-space:nowrap> 
         <thead >
          <tr>
              <th>姓名</th>
              <th>性别</th>
              <th>出生日期</th>
              <th>身份证号</th>
              <th>年龄</th>
              <th>应聘职位</th>
              <th>专业</th>
              <th>学历</th>
              <th>工作经历</th>
              <th>电话</th>
              <th>E-mail</th>
              <th>待审批</th>
              <th>操作</th>



          </tr>
      </thead>
      <tbody>	
       <tr class="rowItem" v-for="item in items">
        <td style="width:60px">{{item.username}}</td>
        <td  style="width:60px">{{item.sex == "1"?"男":"女"}}</td>
        <td style="width:80px">{{item.birthday}}</td>
        <td style="width:60px">{{item.identity}}</td>
        <td style="width:60px">{{item.age}}</td>
        <td style="width:60px">{{item.position}}</td>
        <td style="width:60px">{{item.major}}</td>
        <td style="width:60px">{{item.degree}}</td>
        <td style="width:100px">{{item.experience}}</td>
        <td style="width:60px">{{item.tel}}</td>
        <td style="width:100px">{{item.email}}</td>
        <td style="width:60px">{{item.approval}}</td>
        <td style="width:150px">
          <button v-on:click = "addApproval(item.identity)">提交</button>
          <a href="./update_candidate.html" v-on:click="showDetail(item)">修改</a>
      </td>


  </tr>


</tbody>
</table>

			</div><!-- end of #tab1
			
			<div id="tab2" class="tab_content">

			</div><!-- end of #tab2
			
		</div><!-- end of .tab_container --> 
		
  </article><!-- end of content manager article -->
  <div class="spacer"></div>
  <div>
  </div>		
</section>

<script>
    /**
     * 请求数据
     */
     const vm = new Vue({
        el: "#app",
        data: {
            items: [],
            totalNum: 0,
            currentPage: 0,
            totalPage: 0,
        },
        created: function() {
            var that = this;
          //  alert("...");
          axios.get("http://localhost:8080/javaWeb/listcandidate.action").then(function(res) {
             console.log(res.data);
             if (res.data.status === "1002") {
               console.log(res.data);
               that.items = res.data.data;
               that.totalNum = res.data.totalNumber;
                    //让dom结构渲染完之后在执行下面的goPage()方法
                    that.$nextTick(function() { that.goPage() });
                    console.log(res.data);
                } else {
                    console.log("服务器通讯异常。");
                }
            }).catch(function(e) {
                console.log(e);
            })
        },
        methods: {
            goPage: function(pno) {
                // console.log(this.totalNum);
                pno = pno || 1;
                let pageSize = 9;
                this.totalPage = Math.ceil(this.totalNum / pageSize);
                // console.log(this.totalPage);
                this.currentPage = pno;
                let startRow = (this.currentPage - 1) * pageSize + 1;
                let endRow = this.currentPage * pageSize;
                endRow = (endRow > this.totalNum) ? this.totalNum : endRow;
                // console.log(startRow + "开始  " + endRow + "结束");
                // 遍历显示数据实现分页
                let rows = document.querySelectorAll(".rowItem");
                // console.log(rows);
                for (let i = 1; i <= this.totalNum; i++) {
                    if (i >= startRow && i <= endRow) {
                        rows[i - 1].style.display = "table-row";
                    } else {
                        rows[i - 1].style.display = "none";
                    }
                }
            },
            nextPage: function() {
                if (this.currentPage == this.totalPage) {
                    alert("当前已经是最后一页");
                } else {
                    this.currentPage++;
                    this.goPage(this.currentPage);
                }
            },
            prevPage: function() {
                if (this.currentPage == 1) {
                    alert("当前已经是第一页");
                } else {
                    this.currentPage--;
                    this.goPage(this.currentPage);
                }
            },
            // 显示详情页面
            showDetail: function(user) {
                console.log(user);
                localStorage.setItem("detailUser", JSON.stringify(user));
            },
            updateUser: function(user) {
                localStorage.setItem("updateUser", JSON.stringify(user));
            },
            deleteUser: function(id) {
                let that = this;
                let r = confirm("是否确定删除？");
                if (r) {
                    axios.get("http://localhost:8080/javaWeb/deleteuser.action?id=" + id).then(function(res) {
                        if (res.data.status == "1002") {
                            alert("删除成功");
                            //此时刷新页面
                            location.href="showUser.html";
                        }
                    }).catch(function(err) {
                        console.log(err);
                    });
                }
            },
            addApproval:function (ID_Card) {

                let data = {

                    ID_Card:ID_Card.trim(),

                    operator_num:localStorage.getItem("operator_num"),

                    approver_num:"1002",

                    submit_time:getCurrentTime(),

                    app_status:0

                };

                approvalApi.approval.addApproval(data, function(err, result) {
                    if (err) {
                        alert(err);
                    } else {
                        alert("审批提交成功");
                    }
                });
            }

        }
    });
</script>
<script>

    function search(){

        var searchtext=document.getElementById("searchvalue").value;
        var textvalue=document.getElementById("textvalue").innerHTML;
        if(searchtext.length==0){
            return;
        }
        document.getElementById("textvalue").innerHTML=textvalue.replaceAll(searchtext,"<font color='red'>"+searchtext+"</font>");
    }

    String.prototype.replaceAll = function(s1,s2){    
        return this.replace(new RegExp(s1,"gm"),s2);    
    }
</script>

<script>

    let staff = document.getElementById("staff");

    $(staff).text(localStorage.getItem("username"));

    function getCurrentTime() {

        var date = new Date();

        var month = date.getMonth() + 1;

        var days = date.getDate();

        var year = date.getFullYear();

        var currentTime = year + "/" + month + "/" + days;

        return currentTime;
    }

</script>


</body>

</html>